package com.dy.drp.controller;


import com.dy.drp.dto.PowerDto;
import com.dy.drp.dto.UserDto;
import com.dy.drp.entity.Power;
import com.dy.drp.entity.User;
import com.dy.drp.service.IPowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dy
 * @since 2022-04-01
 */
@RestController
@RequestMapping("/power")
@Api(tags = "权限管理接口")
public class PowerController {
    @Autowired
    private IPowerService powerService;

    @PostMapping("/selectPower")
    @ApiOperation("添加用户时 -- 查询角色拥有的权限")
    public List<PowerDto> selectPower(UserDto userDto){
        return powerService.selectPowerByRole(userDto);
    }

    @GetMapping("/selectAllPower")
    @ApiOperation("添加角色时 -- 查询所有权限")
    public List<Power> selectAllPower(){
        return powerService.list();
    }
}
